-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-10-19
-- Description: DO NOT EDIT; Code generated by "message.lua.mako"
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local def_types = require 'class.types.types'

local MPropertySync = {}

---@class MPropertySync.SyncObjectItems
---@field SyncObjectItems def_types.SyncObjectItem[]
local TSyncObjectItems = {}
TSyncObjectItems.__index = TSyncObjectItems
TSyncObjectItems.group = {}

local function TSyncObjectItems_from_obj(obj)
    obj.SyncObjectItems = utils.from_obj(def_types.SyncObjectItem, obj.SyncObjectItems, true)
    return setmetatable(obj, TSyncObjectItems)
end

function TSyncObjectItems.new(SyncObjectItems)
    return TSyncObjectItems_from_obj({SyncObjectItems = SyncObjectItems})
end
---@param obj MPropertySync.SyncObjectItems
function TSyncObjectItems:init_from_obj(obj)
    self.SyncObjectItems = obj.SyncObjectItems
end

function TSyncObjectItems:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSyncObjectItems.group)
end

TSyncObjectItems.from_obj = TSyncObjectItems_from_obj

TSyncObjectItems.proto_property = {'SyncObjectItems'}

TSyncObjectItems.default = {{}}

TSyncObjectItems.struct = {{name = 'SyncObjectItems', is_array = true, struct = def_types.SyncObjectItem.struct}}

function TSyncObjectItems:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    for _, v in pairs(self.SyncObjectItems) do
        def_types.SyncObjectItem.new(v.Interface, v.Properties):validate(prefix, errs, need_convert)
    end

    TSyncObjectItems:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSyncObjectItems.proto_property, errs, need_convert)
    return self
end

function TSyncObjectItems:unpack(raw)
    return utils.unpack(raw, self.SyncObjectItems, true)
end

MPropertySync.SyncObjectItems = TSyncObjectItems

---@class MPropertySync.SyncObjectName
---@field SyncObjectName string
local TSyncObjectName = {}
TSyncObjectName.__index = TSyncObjectName
TSyncObjectName.group = {}

local function TSyncObjectName_from_obj(obj)
    return setmetatable(obj, TSyncObjectName)
end

function TSyncObjectName.new(SyncObjectName)
    return TSyncObjectName_from_obj({SyncObjectName = SyncObjectName or [=[]=]})
end
---@param obj MPropertySync.SyncObjectName
function TSyncObjectName:init_from_obj(obj)
    self.SyncObjectName = obj.SyncObjectName or [=[]=]
end

function TSyncObjectName:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSyncObjectName.group)
end

TSyncObjectName.from_obj = TSyncObjectName_from_obj

TSyncObjectName.proto_property = {'SyncObjectName'}

TSyncObjectName.default = {''}

TSyncObjectName.struct = {{name = 'SyncObjectName', is_array = false, struct = nil}}

function TSyncObjectName:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'SyncObjectName', self.SyncObjectName, 'string', false, errs, need_convert)

    TSyncObjectName:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSyncObjectName.proto_property, errs, need_convert)
    return self
end

function TSyncObjectName:unpack(_)
    return self.SyncObjectName
end

MPropertySync.SyncObjectName = TSyncObjectName

---@class MPropertySync.TTL
---@field TTL integer
local TTTL = {}
TTTL.__index = TTTL
TTTL.group = {}

local function TTTL_from_obj(obj)
    return setmetatable(obj, TTTL)
end

function TTTL.new(TTL)
    return TTTL_from_obj({TTL = TTL})
end
---@param obj MPropertySync.TTL
function TTTL:init_from_obj(obj)
    self.TTL = obj.TTL
end

function TTTL:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TTTL.group)
end

TTTL.from_obj = TTTL_from_obj

TTTL.proto_property = {'TTL'}

TTTL.default = {0}

TTTL.struct = {{name = 'TTL', is_array = false, struct = nil}}

function TTTL:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'TTL', self.TTL, 'uint32', false, errs, need_convert)

    TTTL:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TTTL.proto_property, errs, need_convert)
    return self
end

function TTTL:unpack(_)
    return self.TTL
end

MPropertySync.TTL = TTTL

---@class MPropertySync.SyncInterval
---@field SyncInterval integer
local TSyncInterval = {}
TSyncInterval.__index = TSyncInterval
TSyncInterval.group = {}

local function TSyncInterval_from_obj(obj)
    return setmetatable(obj, TSyncInterval)
end

function TSyncInterval.new(SyncInterval)
    return TSyncInterval_from_obj({SyncInterval = SyncInterval or 5})
end
---@param obj MPropertySync.SyncInterval
function TSyncInterval:init_from_obj(obj)
    self.SyncInterval = obj.SyncInterval or 5
end

function TSyncInterval:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSyncInterval.group)
end

TSyncInterval.from_obj = TSyncInterval_from_obj

TSyncInterval.proto_property = {'SyncInterval'}

TSyncInterval.default = {0}

TSyncInterval.struct = {{name = 'SyncInterval', is_array = false, struct = nil}}

function TSyncInterval:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'SyncInterval', self.SyncInterval, 'uint8', false, errs, need_convert)

    TSyncInterval:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSyncInterval.proto_property, errs, need_convert)
    return self
end

function TSyncInterval:unpack(_)
    return self.SyncInterval
end

MPropertySync.SyncInterval = TSyncInterval

---@class MPropertySync.SyncMode
---@field SyncMode integer
local TSyncMode = {}
TSyncMode.__index = TSyncMode
TSyncMode.group = {}

local function TSyncMode_from_obj(obj)
    return setmetatable(obj, TSyncMode)
end

function TSyncMode.new(SyncMode)
    return TSyncMode_from_obj({SyncMode = SyncMode or 0})
end
---@param obj MPropertySync.SyncMode
function TSyncMode:init_from_obj(obj)
    self.SyncMode = obj.SyncMode or 0
end

function TSyncMode:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSyncMode.group)
end

TSyncMode.from_obj = TSyncMode_from_obj

TSyncMode.proto_property = {'SyncMode'}

TSyncMode.default = {0}

TSyncMode.struct = {{name = 'SyncMode', is_array = false, struct = nil}}

function TSyncMode:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'SyncMode', self.SyncMode, 'uint8', false, errs, need_convert)

    TSyncMode:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSyncMode.proto_property, errs, need_convert)
    return self
end

function TSyncMode:unpack(_)
    return self.SyncMode
end

MPropertySync.SyncMode = TSyncMode

return MPropertySync
